import { RouteConfig } from 'vue-router'
import Layout from '@/views/layout/index.vue'

/**
 * 需要动态加载的路由
 */
export const routes: Array<RouteConfig> = [
  {
    path: '/login',
    name: 'login',
    meta: {
      hidden: true
    },
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/',
    component: Layout,
    meta: {
      requiresAuth: true,
      hidden: true
    },
    children: [
      {
        path: '',
        name: 'home',
        meta: {
          hidden: true, // 是否在侧边栏显示
          icon: 'el-icon-s-home'
        },
        component: () => import('@/views/home/index.vue')
      }
    ]
  },
  {
    path: '/auth',
    name: 'auth',
    component: Layout,
    meta: {
      requiresAuth: true,
      title: '用户管理',
      icon: 'el-icon-user-solid'
    },
    children: [
      {
        path: '/user',
        name: 'user',
        meta: {
          title: '用户列表',
          icon: 'el-icon-user-solid',
          hidden: false
        },
        component: () => import('@/views/home/index.vue')
      },
      {
        path: '/auth/role',
        name: 'role',
        meta: {
          title: '角色列表',
          icon: 'el-icon-bank-card',
          hidden: false
        },
        component: () => import('@/views/home/index.vue')
      }
    ]
  },
  {
    path: '/servers',
    name: 'servers',
    component: Layout,
    meta: {
      requiresAuth: true,
      title: '服务管理',
      icon: 'el-icon-user-solid'
    },
    children: [
      {
        path: '/servers/list',
        name: 'server',
        meta: {
          title: '服务管理',
          hidden: false
        },
        component: () => import('@/views/home/index.vue')
      }
    ]
  },
  {
    path: '*',
    name: '404',
    meta: {
      hidden: true
    },
    component: () => import('@/views/error-page/404.vue')
  }
]
